import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useLoginUserStore =  defineStore('loginUser', () => {
  const loginUser = ref({
    userName: '未登录'
  })

  function fetchLoginUser() {
    // 需要后台提供接口登录
    console.log('fetchLoginUser...')
    setTimeout(() => {
      setLoginUser({id: 1, userName: "测试用户1"})
    }, 3000)
  }

  function setLoginUser(newLoginUser: any) {
    loginUser.value = newLoginUser;
  }

  return {
    loginUser, fetchLoginUser, setLoginUser
  }
})
